#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[30005], vis[30005];

signed main() {
	int w, n;
	cin >> w >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) {
		if (vis[i])
			continue;

		vis[i] = 1;
		ans++;

		int target = w - a[i];
		int idx = upper_bound(a + i, a + n + 1, target) - a;
		for (int j = idx - 1; j > i; j--) {
			if (!vis[j]) {
				vis[j] = 1;
				break;
			}
		}
	}
	cout << ans ;
	return 0;
}
